home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / lib / gcc-lib / djgpp / 2.952 / units / trapc.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-08  |  1.7 KB  |  60 lines

  1. /*
  2. Support routines for the Trap unit
  3.  
  4. Copyright (C) 1998-2001 Free Software Foundation, Inc.
  5.  
  6. Author: Frank Heckenbach <frank@pascal.gnu.de>
  7.  
  8. This file is part of GNU Pascal.
  9.  
  10. GNU Pascal is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2, or (at your option)
  13. any later version.
  14.  
  15. GNU Pascal is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with GNU Pascal; see the file COPYING. If not, write to the
  22. Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  23. 02111-1307, USA.
  24.  
  25. As a special exception, if you link this file with files compiled
  26. with a GNU compiler to produce an executable, this does not cause
  27. the resulting executable to be covered by the GNU General Public
  28. License. This exception does not however invalidate any other
  29. reasons why the executable file might be covered by the GNU General
  30. Public License.
  31. */
  32.  
  33. #include <setjmp.h>
  34.  
  35. /* jmp_buf may be an array which doesn't allow assignments in :-C,
  36.    so wrap it up in a struct. */
  37. typedef struct
  38. {
  39.   jmp_buf buf;
  40. } jmp_buf_struct;
  41.  
  42. jmp_buf_struct state;
  43.  
  44. void dosetjmp (void (*p) (unsigned char));
  45. void dosetjmp (void (*p) (unsigned char))
  46. {
  47.   volatile jmp_buf_struct prev = state;  /* setjmp requires `volatile' */
  48.   if (setjmp (state.buf) != 0)  /* Don't use setjmp in an argument list or ?: */
  49.     (*p) (1);
  50.   else
  51.     (*p) (0);
  52.   state = prev;
  53. }
  54.  
  55. void dolongjmp (void);
  56. void dolongjmp (void)
  57. {
  58.   longjmp (state.buf, 1);
  59. }
  60.